package com.robam.cloud.authcenter.controller;


import com.robam.cloud.authcenter.service.WechatService;
import com.robam.cloud.common.bean.authcenter.entity.WechatSignParam;
import com.robam.cloud.common.bean.restful.entity.RespMsg;
import com.robam.cloud.log.annotation.OperationLogRecord;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.hibernate.validator.constraints.NotBlank;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;

@Api("微信控制类")
@RestController
@RequestMapping("/wechat")
public class WechatController {
    @Autowired
    HttpServletRequest httpServletRequest;
    @Autowired
    WechatService wechatService;

    @ApiOperation(
            value = "获取微信接口参数",
            notes = "获取微信接口参数")
    @RequestMapping(
            value = "/getSignParams",
            method = RequestMethod.GET)
    @OperationLogRecord(
            describe = "获取微信接口参数",
            modularCode = "wechat-getSignParams",
            operationLevel = OperationLogRecord.OperationLevel.OTHER)
    public RespMsg<WechatSignParam> getSignParams(@RequestParam @Valid @NotBlank String url) {
        return RespMsg.success(wechatService.getSignParams(url, httpServletRequest));
    }


    @ApiOperation(
            value = "获取微信接口参数-扫脸用",
            notes = "获取微信接口参数-扫脸用")
    @RequestMapping(
            value = "/getSignParamsFace",
            method = RequestMethod.GET)
    @OperationLogRecord(
            describe = "获取微信接口参数-扫脸用",
            modularCode = "wechat-getSignParamsFace",
            operationLevel = OperationLogRecord.OperationLevel.OTHER)
    public RespMsg<WechatSignParam> getSignParamsFace(@RequestParam @Valid @NotBlank String url) {
        return RespMsg.success(wechatService.getSignParamsFace(url, httpServletRequest));
    }
}
